home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / quake.zip / HIPGRAPL.ZIP / CHAIN.QC < prev    next >
Text File  |  1997-04-27  |  9KB  |  294 lines

  1. /*
  2.  
  3. hook.dest = Last Origin of Owner
  4. hook.style = Current chain sound
  5.  
  6. */
  7.  
  8.  
  9. /************\
  10. * BreakChain *
  11. \************/
  12.  
  13. void (entity Head) BreakChain =
  14. {
  15.         local entity link;
  16.  
  17.         link = Head.goalentity;
  18.         while (link != world)
  19.         {
  20.                 Head = link.goalentity;
  21.                 remove (link);
  22.                 link = Head;
  23.         }
  24. };
  25.  
  26. /*********\
  27. * LinkPos *
  28. \*********/
  29.  
  30. void () LinkPos =
  31. {
  32.         makevectors (self.enemy.angles);
  33.         setorigin (self, self.owner.origin + ( ( ( self.enemy.origin + 
  34.                 (v_up * 20 * (!self.enemy.button2)) + (v_forward * 16) ) - self.owner.origin ) *
  35.                 ( self.weapon ) ) );
  36.         self.nextthink = time + 0.01;
  37. };
  38.  
  39. /***********\
  40. * MakeChain *
  41. \***********/
  42.  
  43. entity (entity head, entity tail, float num) MakeChain =
  44. {
  45.         local entity link, prevlink;
  46.         local float linknum;
  47.  
  48.         linknum = num;
  49.         num = num + 1;
  50.         prevlink = world;
  51.         while (linknum > 0)
  52.         {
  53.                 link = spawn();
  54.  
  55.                 link.goalentity = prevlink;
  56.                 prevlink = link;
  57.  
  58.                 link.owner = head;
  59.                 link.enemy = tail;
  60.                 link.weapon = linknum / num;
  61.                 link.movetype = MOVETYPE_NOCLIP;
  62.                 link.solid = SOLID_NOT;
  63.                 link.angles_z = 51 * linknum;
  64.                 link.angles_y = 41 * linknum;
  65.                 link.angles_x = 31 * linknum;
  66.                 link.avelocity = '310 410 510';
  67.                 setmodel (link, "progs/bit.mdl");
  68.                 setsize (link, '0 0 0', '0 0 0');
  69.                 makevectors (tail.angles);
  70.                 setorigin (link, head.origin + ( ( ( tail.origin 
  71.                         + (v_up * 20 * (!tail.button2)) + ( v_forward * 16 ) ) - head.origin )
  72.                         * ( link.weapon ) ) );
  73.                 link.nextthink = time + 0.01;
  74.                 link.think = LinkPos;
  75.                 linknum = linknum - 1;
  76.         }
  77.         return link;
  78. };
  79.  
  80.  
  81. /************\
  82. * HookVanish *
  83. \************/
  84.  
  85. void () HookVanish =
  86. {
  87.         self.owner.hook_out = FALSE;
  88.         if (self.enemy.classname == "player")
  89.                 self.enemy.attack_finished = time + 0.1;
  90.         sound (self.owner, CHAN_WEAPON, "weapons/bounce2.wav", 1, ATTN_NORM);
  91.         BreakChain (self);
  92.         remove (self);
  93. };
  94.  
  95. /**********\
  96. * HookPull *
  97. \**********/
  98.  
  99. void () HookPull =
  100. {
  101.         local vector vel, spray;
  102.         local float v, dorg;
  103.  
  104.         if ((!self.owner.button0 && (self.owner.weapon == IT_MORNINGSTAR)) ||
  105.                 (self.owner.teleport_time > time ) || self.owner.deadflag )
  106.         {
  107.                 if (self.enemy.takedamage && (self.weapon > 0))
  108.                 {       self.enemy.nextthink = time + 0.1; }
  109.                 HookVanish();
  110.                 return;
  111.         }
  112.         else
  113.         {
  114.                 makevectors (self.owner.angles);
  115.                 vel = self.origin - ( self.owner.origin + (v_up * 20 *
  116.                         ((1.25 * (!self.owner.button2)) - 0.25)) + (v_forward
  117.                         * 16));
  118.                 v = vlen (vel);
  119.                 if (v <= 100)
  120.                         vel = normalize(vel) * v * 10;  
  121.                 else
  122.                     // KD - doubled the pull speed
  123.                     //  vel = normalize(vel) * 1000;
  124.                         vel = normalize(vel) * 2000;
  125.  
  126.                 dorg = vlen (self.owner.origin - self.dest);
  127.                 if ( ( dorg > 10 ) && (self.style == 3) )
  128.                 {
  129.                         sound (self.owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM);
  130.                         self.style = 2;
  131.                 }
  132.                 if ( (dorg < 10) && (self.style == 2) )
  133.                 {
  134.                         sound (self.owner, CHAN_WEAPON, "weapons/chain3.wav", 1, ATTN_NORM);
  135.                         self.style = 3;
  136.                 }
  137.                 self.owner.velocity = vel;
  138.                 self.dest = self.owner.origin;
  139.                 if (self.enemy.takedamage)
  140.                 {
  141.                         sound (self, CHAN_WEAPON, "blob/land1.wav", 1, ATTN_NORM);
  142.                         T_Damage (self.enemy, self, self.owner, 1);
  143.                         makevectors (self.v_angle);
  144.                         spray_x = 100 * crandom();
  145.                         spray_y = 100 * crandom();
  146.                         spray_z = 100 * crandom() + 50;
  147.                         SpawnBlood (self.origin, spray, 20);
  148.  
  149.                         // KD - removed this due to EXTREME annoyance
  150.                         //      at not being able to retaliate.
  151.                         //      If someone's hanging off of me by a chain
  152.                         //      embedded in my crotch, you better damn well
  153.                         //      believe I'll make use of that rocket launcher.
  154.                         /*
  155.                         if (self.weapon > 0)
  156.                         {
  157.                                 self.enemy.nextthink = time + 9999999;
  158.                                 if (self.enemy.classname == "player")
  159.                                         self.enemy.attack_finished = time + 9999999;
  160.                         }
  161.                         */
  162.  
  163.                         if (self.enemy.health <= 0)
  164.                         {
  165.                                 if (self.weapon > 0)
  166.                                         self.enemy.nextthink = time + 0.1;
  167.                         }
  168.                         if (self.enemy.solid == SOLID_SLIDEBOX)
  169.                         {
  170.                                 self.velocity = '0 0 0';
  171.                                 setorigin (self, self.enemy.origin +
  172.                                         self.enemy.mins +
  173.                                         (self.enemy.size * 0.5));
  174.                         }
  175.                         else
  176.                         {
  177.                                 self.velocity = self.enemy.velocity;
  178.                         }
  179.                 }
  180.                 else
  181.                 {
  182.                         self.velocity = self.enemy.velocity;                             
  183.                 }
  184.                 if (self.enemy.solid == SOLID_NOT)
  185.                 {
  186.                         HookVanish();
  187.                         return;
  188.                 }
  189.                 self.nextthink = time + 0.1;
  190.                 self.think = HookPull;
  191.         }
  192. };
  193.  
  194. /**************\
  195. * T_ChainTouch *
  196. \**************/
  197.  
  198. void() T_ChainTouch =
  199. {
  200.         local float rand;
  201.  
  202.         if (other == self.owner)
  203.                 return;         // don't attach to owner
  204.  
  205.     if (pointcontents(self.origin) == CONTENT_SKY)
  206.     {
  207.                 HookVanish();
  208.                 return;
  209.     }
  210.  
  211.         if (other.takedamage)
  212.     {
  213.                 T_Damage (other, self, self.owner, 10 );
  214.                 SpawnBlood (self.origin, self.velocity, 10);
  215.         }
  216.         else
  217.         {
  218.                 self.avelocity = '0 0 0';
  219.         }
  220.                 
  221.       sound (self, CHAN_AUTO, "weapons/bounce.wav", 1, ATTN_NORM);
  222.  
  223.         if (!self.owner.button0)
  224.         {
  225.                 HookVanish();
  226.                 return;
  227.         }
  228.         else
  229.         {
  230.                 if (other.solid == SOLID_SLIDEBOX)
  231.                 {
  232.                         setorigin (self, other.origin + other.mins +
  233.                                 (other.size * 0.5));
  234.                         self.velocity = '0 0 0';
  235.                         rand = random();
  236.                         if (rand <= (vlen(other.origin - self.owner.origin) * 0.001))
  237.                                 sound (self.owner, CHAN_VOICE, "weapons/gotcha.wav",
  238.                                 1, ATTN_STATIC);
  239.                 }
  240.                 else
  241.                 {
  242.                         self.velocity = other.velocity;
  243.                 }
  244.                 self.weapon = other.nextthink - time;
  245.                 sound (self.owner, CHAN_WEAPON, "weapons/chain2.wav", 1, ATTN_NORM);
  246.                 self.style = 2;
  247.                 self.enemy = other;
  248.                 self.think = HookPull;
  249.                 self.nextthink = time + 0.1;
  250.                 self.touch = SUB_Null;
  251.         }
  252. };
  253.  
  254. /*************\
  255. * W_FireChain *
  256. \*************/
  257.  
  258. void() W_FireChain =
  259. {
  260.         local entity hook;
  261.  
  262.         self.hook_out = TRUE;
  263.         hook = spawn ();
  264.         hook.owner = self;
  265.         hook.movetype = MOVETYPE_FLY;
  266.         hook.solid = SOLID_BBOX;
  267.         
  268. // set hook speed 
  269.  
  270.         makevectors (self.v_angle);
  271.  
  272. // KD - doubled firing speed to allow easier life-saving on HIPDM1
  273. //        hook.velocity = aim(self, 1000);
  274. //        hook.velocity = hook.velocity * 1000;
  275.         hook.velocity = aim(self, 2000);
  276.         hook.velocity = hook.velocity * 2000;
  277.  
  278.         hook.angles = vectoangles(hook.velocity);
  279.         hook.avelocity = '0 0 -500';
  280.     
  281.         hook.touch = T_ChainTouch;
  282.     
  283. // set hook sound
  284.         hook.think = HookVanish;
  285.         hook.nextthink = time + 5;
  286.  
  287.         setmodel (hook, "progs/star.mdl");
  288.         setsize (hook, '0 0 0', '0 0 0');     
  289.         setorigin (hook, self.origin + (v_forward*16) + '0 0 20' );
  290.         sound (self, CHAN_WEAPON, "weapons/chain1.wav", 1, ATTN_NORM);
  291.  
  292.         hook.goalentity = MakeChain (hook, self, 8);
  293. };
  294.